/*
 * tiny.c - A simple,iterative HTTP/1.0 Web server that use the
 * Get method to server static and dynamic content.
 */
#include "../csapp.h"
#include "tiny.h"

int test_tiny(int argc, char **argv)
{
	int listenfd, connfd, port, clientlen;
	struct sockaddr_in clientaddr;
	
	/* Check command line args*/
	if (argc != 2)
	{
		fprintf(stderr,"usage: %s <prot>\n",argv[0]);
		exit(1);
	}
	port = atoi(argv[1]);
	
	if ((listenfd = open_listenfd(port)) < 0)
	{
		fprintf(stderr,"bad descriptor");
		return -1;
	}

	while (1)
	{
		clientlen = sizeof(clientaddr);
		connfd = Accept(listenfd, (SA *)&clientaddr, (socklen_t *)&clientlen);
		doit(connfd);
		Close(connfd);
	}
	
}

